/*********************************************************************************************************
 *  ------------------------------------------------------------------------------------------------------
 *  file description
 *  ------------------------------------------------------------------------------------------------------
 *         \file  map_cfg.c
 *        \brief  This is a general-purpose C language map module configuration file
 *       \author  Lamdonn
 *        \email  Lamdonn@163.com
 *      \version  1.1.0
 *      \license  GPL2
 *    \copyright  Copyright (C) 2023 Lamdonn.
 ********************************************************************************************************/
#include "map_cfg.h"
#include "../map.h"
#include <string.h>

extern map_key_t *map_nil_key(void *map);

/* key type general macro definition */
#define address                         (map_nil_key(map)->address)
#define size                            (map_nil_key(map)->size)
#define ret                             (map_nil_key(map))

/** 
 *  \brief key transform function of type int
 *  \param[in] map: map handler
 *  \param[in] key: int key
 *  \return address of key
 */
void* map_key_trans__int(void* map, int key)
{
    *(int *)address = key;
    size = sizeof(int);
    return ret;
}

/** 
 *  \brief key transform function of type char
 *  \param[in] map: map handler
 *  \param[in] key: char key
 *  \return address of key
 */
void* map_key_trans__char(void* map, char key)
{
    *(char *)address = key;
    size = sizeof(char);
    return ret;
}

/** 
 *  \brief key transform function of type short
 *  \param[in] map: map handler
 *  \param[in] key: char key
 *  \return address of key
 */
void* map_key_trans__short(void* map, short key)
{
    *(short *)address = key;
    size = sizeof(short);
    return ret;
}

/** 
 *  \brief key transform function of type long
 *  \param[in] map: map handler
 *  \param[in] key: char key
 *  \return address of key
 */
void* map_key_trans__long(void* map, long key)
{
    *(long *)address = key;
    size = sizeof(long);
    return ret;
}

/** 
 *  \brief key transform function of type char* string
 *  \param[in] map: map handler
 *  \param[in] key: string key
 *  \return address of key
 */
void* map_key_trans__string(void* map, string key)
{
    address = key;
    size = strlen(key) + 1;
    return ret;
}

/** 
 *  \brief key transform function of type float
 *  \param[in] map: map handler
 *  \param[in] key: float key
 *  \return address of key
 */
void* map_key_trans__float(void* map, float key)
{
    *(float *)address = key;
    size = sizeof(float);
    return ret;
}

/** 
 *  \brief key transform function of type double
 *  \param[in] map: map handler
 *  \param[in] key: double key
 *  \return address of key
 */
void* map_key_trans__double(void* map, double key)
{
    *(double *)address = key;
    size = sizeof(double);
    return ret;
}

/*********************************************************************************************************
 * add other key type transform function here
 ********************************************************************************************************/

